<template>
  <nav>
    <strong>已发送邮件</strong>
  </nav>
  <main>
    <el-scrollbar height="500px">
      <router-link v-for="item in list" :key="item.id" :to="`/info/mails/${item.id}`">
        <div class="info-card">
          <div class="card-top">
            <span>{{ item.sender.name }}</span>
            <span class="time" style="margin-left: 10px;">{{ formatDate(item.date_time) }}</span>
          </div>
          <div class="card-content">
            <span><strong>{{ item.title }}</strong></span>
          </div>
        </div>
      </router-link>
    </el-scrollbar>
  </main>
</template>

<script>
import { post } from '../../../utils/common/api';
export default {
  data() {
    return {
      form: {
        did: undefined,
        pid: undefined,
        system: undefined,
      },
      departList: [],
      projectList: [],
      list: [],
    }
  },
  methods: {
    async getInfoMailSenderList() {
      const res = await post('/info/mail/sender/list', {})
      this.list = res.list.reverse()
    },

    async loadData() {
      await this.getInfoMailSenderList()
    },

    formatDate(dateTime) {
      // 根据实际需要格式化日期时间
      return `${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}:${dateTime.second}`;
    },
  },

  mounted() {
    this.loadData()
  },
}
</script>

<style scoped>
header {
  width: 100%;
  /* height: 100px; */
  padding: 8px;
  box-sizing: border-box;
  /* background-color: #294c82; */
  display: flex;
  align-items: center;
}

nav {
  padding: 10px;
  display: flex;
  box-shadow: 0 2px 4px 0 rgba(121, 146, 185, 0.54);
  border-radius: 4px;
}

.el-select {
  margin: 0 15px 0 15px;
}

.notice-card {
  padding: 2px;
  background-color: #fff;
}

.notice-card:hover {
  background-color: rgb(207, 228, 250);
}

.info-card {
  color: rgb(48, 49, 51);
  /* width: 820px; */
  padding: 24px 16px;
  line-height: 24px;
  margin-bottom: 10px;
  margin: 5px auto;
  background-color: #fff;
  box-sizing: border-box;
  border-radius: 4px;
  box-shadow: 0 2px 4px 0 rgba(121, 146, 185, 0.54);
}

.info-card:hover {
  background-color: rgb(245, 245, 245);
}

.time {
  color: #999;
  font-size: 12px;
  line-height: 22px;
  margin: 0 10px;
}

.card-top {
  display: flex;
  align-items: center;
}

.el-scrollbar__view {
  margin: 0 auto;
}
</style>